import requests

from IHRM01.common.get_header import get_header


class IhrmEmpApi:
    #定义添加员工的方法
    @classmethod
    def emp_add(cls,headers,req_data):
        resp=requests.post(url="https://heimahr-t.itheima.net/api/sys/user",
                      headers=headers,
                      json=req_data,
            )
        return resp

# print(resp.json())
    #定义员工查询的方法、
    @classmethod
    def query_emp(cls,emp_id,headers):
        resp1 = requests.get(url="https://heimahr-t.itheima.net/api/sys/user/"+str(emp_id),
                      headers=headers
                      )
        return resp1

    #定义员工修改的方法
    @classmethod
    def put_emp(cls,emp_id,header,req_data):
        resp2 = requests.put(url="https://heimahr-t.itheima.net/api/sys/user/"+str(emp_id),
                    headers=headers,
                     json=req_data,
                     )
        return resp2

    #定义员工删除的方法
    @classmethod
    def del_emp(cls,emp_id,header):
        resp3 = requests.delete(url="https://heimahr-t.itheima.net/api/sys/user/"+str(emp_id),
                                headers=headers,
                                )
        return resp3
if __name__ == '__main__':
    # headers={"Authorization" :"Bearer "+"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2Vy"
    #                                     "SWQiOjEsImlhdCI6MTc0NDI4MjE5OCwiZXhwIjoxNzQ0MzAzNzk"
    #                                     "4fQ.24M0IlRbLJTufJKXvoj-5RiBrxX5X2ffnxk0b9IiKv0"}
    # req_data={
    #     "username": "方童",
    #         "mobile": "13698745242",
    #         "workNumber": "",
    #         "formOfEmployment": 1,
    #         "departmentId": 11,
    #         "timeOfEntry": "2025-04-06",
    #         "correctionTime": "2025-04-18T16:00:00.000Z",
    #         "staffPhoto": ""
    # }
    # resp=IhrmEmpApi.test_emp_add(headers,req_data)
    # print(resp.json())
    headers =get_header()
    # resp=IhrmEmpApi.query_emp(4366,headers)
    # print(resp.json())
    # req_data = {'id': 4366, 'mobile': '13698745242', 'staffPhoto': '', 'username': '方婷', 'workNumber': 'HEIMA04681', 'timeOfEntry': '2025-04-06', 'correctionTime': '2025-04-19', 'departmentId': 11, 'departmentName': '薪资管理部', 'formOfEmployment': 1, 'roleIds': []}
    # resp=IhrmEmpApi.put_emp(4366,headers,req_data)
    # print(resp.json())
    resp=IhrmEmpApi.del_emp(4376,headers)
    print(resp.json())